from cyaron import *

#predata
name = "cell"

for i in range(1, 11):
    test_data = IO(file_prefix=name, data_id=i)
    # make data
    while True:
        n = randint(1, 1000)
        k = randint(1, 100)
        ans = randint(0, 15)
        m = n * (1 + k) ** ans
        if m <= 10**9:
            if ans == 0:
                m = randint(1, m-1)
            else:
                m = randint(n*(1+k)**(ans-1)+1, m)
            break
    
    # writeln data
    test_data.input_writeln(n,k,m)
    # run data by shell
    test_data.output_gen("./"+name)